﻿package net.xxcl.news.business;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import net.xxcl.news.pojo.Type;
import net.xxcl.news.util.DBConnection;

/**
 * @author Administrator
 * 新闻主题的业务逻辑类
 */
public class TypeBiz {
	/**
	 * 根据id查找主题
	 * @param id
	 * @return
	 */
	public Type selectById(int id) {
		DBConnection dbConnection = new DBConnection();
		//新的 
		Type t = new Type();
		try {
			//sql语句					
			String sql = "select * from type where id=?";
			PreparedStatement pstmt = dbConnection.getConnection().prepareStatement(sql);
			pstmt.setInt(1, id);
			ResultSet rs = pstmt.executeQuery();
			if(rs.next()){
				t.setId(id);
				t.setName(rs.getString("name"));
				t.setRemarks(rs.getString("remarks"));
			}			
		} catch (SQLException e) {
			e.printStackTrace();
		} finally {
			dbConnection.close();
		}
		return t;
	}
}
